let Koa=require('koa');
let Router=require('koa-router');

let app=new Koa();
let router=new Router();

router.get('/user',ctx=>{
    ctx.body="test";
});

router.get('/abc/:id',async (ctx,next)=>{
    let userId=ctx.params.id;
    ctx.body=userId;
})
app.use(router.routes());

// app.use(router.routes()).use(router.allowedMethods());//router.allowedMethods()是中间件

app.listen(8080,()=>{
    console.log("监听成功，服务器运行在http://localhost:8080");
})